Qualcomm CPR (Core Power Reduction) Regulator

CPR regulator device is for Qualcomm RBCPR (RapidBridge CPR) on
	application processor core. It takes voltage corner level
	as input and converts it to actual voltage based on the
	suggestions from factory production process. When CPR is
	enabled for application processer core, it will suggest
	scaling the voltage up or down for best performance and
	power of the core. The scaling based on factory production
	process is called PVS (Process Voltage Scaling) with efuse
	bits to indicate what bin (and voltage range) a chip is in.

Required properties:
- compatible:			Must be "qcom,cpr-regulator"
- reg:				Register addresses for RBCPR, RBCPR clock
				select, PVS and CPR eFuse address
- reg-names:			Register names. Must be "rbcpr", "rbcpr_clk",
				"efuse_addr"
- regulator-name:		A string used to describe the regulator
- interrupts:			Interrupt line from RBCPR to interrupt controller.
- regulator-min-microvolt:	Minimum corner value as min constraint, which
				should be 1 for SVS corner
- regulator-max-microvolt:	Maximum corner value as max constraint, which
				should be 4 for SUPER_TURBO or 3 for TURBO
- qcom,pvs-voltage-table: 	Array of triples in which each triple indicates the initial voltage
				of the PVS bin in SVS, NOM and Turbo corner in microvolts.
				The location or 0-based index of an triple in the
				list corresponds to the bin number.
- qcom,cpr-voltage-ceiling:	Ceiling voltages of SVS, NOM and TURBO corners respectively
- qcom,cpr-voltage-floor:	Floor voltages of SVS, NOM and TURBO corners respectively
				The ceiling voltages for each of above two
				properties may look like this:
				  0 (SVS voltage):		1050000 uV
				  1 (NORMAL voltage):		1150000 uV
				  2 (TURBO voltage):		1275000 uV
- vdd-apc-supply:		Regulator to supply VDD APC power
- qcom,vdd-apc-step-up-limit:	Limit of vdd-apc-supply steps for scaling up.
- qcom,vdd-apc-step-down-limit:	Limit of vdd-apc-supply steps for scaling down.
- qcom,cpr-ref-clk:		The reference clock in kHz.
- qcom,cpr-timer-delay:		The delay in microseconds for the timer interval.
- qcom,cpr-timer-cons-up:	Consecutive number of timer interval (qcom,cpr-timer-delay)
				occurred before issuing UP interrupt.
- qcom,cpr-timer-cons-down:	Consecutive number of timer interval (qcom,cpr-timer-delay)
				occurred before issuing DOWN interrupt.
- qcom,cpr-irq-line:		Internal interrupt route signal of RBCPR, one of 0, 1 or 2.
- qcom,cpr-step-quotient:	Number of CPR quotient (Ring Oscillator(RO) count) per vdd-apc-supply step
				to issue error_steps.
- qcom,cpr-up-threshold:	The threshold for CPR to issue interrupt when
				error_steps is greater than it when stepping up.
- qcom,cpr-down-threshold:	The threshold for CPR to issue interrupt when
				error_steps is greater than it when stepping down.
- qcom,cpr-idle-clocks:		Idle clock cycles RO can be in.
- qcom,cpr-gcnt-time:		The time for gate count in microseconds.
- qcom,cpr-apc-volt-step:	The voltage in microvolt per CPR step, such as 5000uV.

- qcom,pvs-fuse-redun-sel:	Array of 5 elements to indicate where to read the bits, what value to
				compare with in order to decide if the redundant PVS fuse bits would be
				used instead of the original bits and method to read fuse row, reading
				register through SCM or directly. The 5 elements with index [0..4] are:
				  [0] => the fuse row number of the selector
				  [1] => LSB bit position of the bits
				  [2] => number of bits
				  [3] => the value to indicate redundant selection
				  [4] => fuse reading method, 0 for direct reading or 1 for SCM reading
				When the value of the fuse bits specified by first 3 elements equals to
				the value in 4th element, redundant PVS fuse bits should be selected.
				Otherwise, the original PVS bits should be selected. If the 5th
				element is 0, read the fuse row from register directly. Otherwise,
				read it through SCM.
- qcom,pvs-fuse:			Array of 4 elements to indicate the bits for PVS fuse and read method.
				The array should have index and value like this:
				  [0] => the PVS fuse row number
				  [1] => LSB bit position of the bits
				  [2] => number of bits
				  [3] => fuse reading method, 0 for direct reading or 1 for SCM reading
- qcom,pvs-fuse-redun:		Array of 4 elements to indicate the bits for redundant PVS fuse.
				The array should have index and value like this:
				  [0] => the redundant PVS fuse row number
				  [1] => LSB bit position of the bits
				  [2] => number of bits
				  [3] => fuse reading method, 0 for direct reading or 1 for SCM reading
- qcom,cpr-fuse-redun-sel:	Array of 5 elements to indicate where to read the bits, what value to
				compare with in order to decide if the redundant CPR fuse bits would be
				used instead of the original bits and method to read fuse row, using SCM
				to read or read register directly. The 5 elements with index [0..4] are:
				  [0] => the fuse row number of the selector
				  [1] => LSB bit position of the bits
				  [2] => number of bits
				  [3] => the value to indicate redundant selection
				  [4] => fuse reading method, 0 for direct reading or 1 for SCM reading
				When the value of the fuse bits specified by first 3 elements equals to
				the value in 4th element, redundant CPR fuse bits should be selected.
				Otherwise, the original CPR bits should be selected. If the 5th element
				is 0, read the fuse row from register directly. Otherwise, read it through
				SCM.
- qcom,cpr-fuse-row:		Array of row number of CPR fuse and method to read that row. It should have
				index and value like this:
				 [0] => the fuse row number
				 [1] => fuse reading method, 0 for direct reading or 1 for SCM reading
- qcom,cpr-fuse-bp-cpr-disable:	Bit position of the bit to indicate if CPR should be disable
- qcom,cpr-fuse-bp-scheme:	Bit position of the bit to indicate if it's a global/local scheme
- qcom,cpr-fuse-target-quot:	Array of bit positions in fuse for Target Quotient of all corners.
				It should have index and value like this:
				  [0] => bit position of the LSB bit for SVS target quotient
				  [1] => bit position of the LSB bit for NOMINAL target quotient
				  [2] => bit position of the LSB bit for TURBO target quotient
- qcom,cpr-fuse-ro-sel:		Array of bit positions in fuse for RO select of all corners.
				It should have index and value like this:
				  [0] => bit position of the LSB bit for SVS RO select bits
				  [1] => bit position of the LSB bit for NOMINAL RO select bits
				  [2] => bit position of the LSB bit for TURBO RO select bits
- qcom,cpr-fuse-redun-row:	Array of row number of redundant CPR fuse and method to read that
				row. It should have index and value like this:
				 [0] => the redundant fuse row number
				 [1] => the value to indicate reading the fuse row directly or using SCM
- qcom,cpr-fuse-redun-target-quot:	Array of bit positions in fuse for redundant Target Quotient of all corners.
				It should have index and value like this:
				  [0] => bit position of the LSB bit for redundant SVS target quotient
				  [1] => bit position of the LSB bit for redundant NOMINAL target quotient
				  [2] => bit position of the LSB bit for redundant TURBO target quotient
- qcom,cpr-fuse-redun-ro-sel:	Array of bit positions in eFuse for redundant RO select.
				It should have index and value like this:
				  [0] => bit position of the LSB bit for redundant SVS RO select bits
				  [1] => bit position of the LSB bit for redundant NOMINAL RO select bits
				  [2] => bit position of the LSB bit for redundant TURBO RO select bits


Optional properties:
- vdd-mx-supply:		Regulator to supply memory power as dependency
				of VDD APC.
- qcom,vdd-mx-vmax:		The maximum voltage in uV for vdd-mx-supply. This
				is required when vdd-mx-supply is present.
- qcom,vdd-mx-vmin-method:	The method to determine the minimum voltage for
				vdd-mx-supply, which can be one of following
				choices compared with VDD APC:
				  0 => equal to the voltage(vmin) of VDD APC
				  1 => equal to PVS corner ceiling voltage
				  2 => equal to slow speed corner ceiling
				  3 => equal to qcom,vdd-mx-vmax
				  4 => equal to VDD_APC corner mapped vdd-mx voltage
				This is required when vdd-mx-supply is present.
- qcom,vdd-mx-corner-map:	Array of 3 elements which defines the mapping from VDD_APC
				fuse voltage corners to vdd-mx-supply voltages.
				The 3 elements with index[0..2] are:
				[0] => voltage to set for vdd-mx when VDD_APC is running at SVS corner
				[1] => voltage to set for vdd-mx when VDD_APC is running at NOM corner
				[2] => voltage to set for vdd-mx when VDD_APC is running at TURBO corner
				This is required when the qcom,vdd-mx-vmin-method property has a value of 4.
- qcom,cpr-fuse-redun-bp-cpr-disable:	Redundant bit position of the bit to indicate if CPR should be disable
- qcom,cpr-fuse-redun-bp-scheme:	Redundant bit position of the bit to indicate if it's a global/local scheme
					This property is required if cpr-fuse-redun-bp-cpr-disable
					is present, and vise versa.
- qcom,cpr-enable:		Present: CPR enabled by default.
				Not Present: CPR disable by default.
- qcom,cpr-fuse-cond-min-volt-sel:	Array of 5 elements to indicate where to read the bits,  what value to
				compare with in order to decide if the conditional minimum apc voltage needs
				to be applied and the fuse reading method.
				The 5 elements with index[0..4] are:
				[0] => the fuse row number;
				[1] => LSB bit position of the bits;
				[2] => number of the bits;
				[3] => the expected data to read;
				[4] => fuse reading method, 0 for direct reading or 1 for SCM reading;
				When the value of the fuse bits specified by first 3 elements is not equal to
				the value in 4th element, then set the apc voltage for all parts running
				at each voltage corner to be not lower than the voltage defined
				using "qcom,cpr-cond-min-voltage".
- qcom,cpr-cond-min-voltage:	Minimum voltage in microvolts for SVS, NOM and TURBO mode if the fuse bits
				defined in qcom,cpr-fuse-cond-min-volt-sel have not been programmed with the
				expected data. This is required if cpr-fuse-cond-min-volt-sel is present.
- qcom,cpr-fuse-uplift-sel: 	Array of 5 elements to indicate where to read the bits, what value to
				compare with in order to enable or disable the pvs voltage uplift workaround,
				and the fuse reading method.
				The 5 elements with index[0..4] are:
				[0]: => the fuse row number of the selector;
				[1]: => LSB bit position of the bits;
				[2]: => number of the bits;
				[3]: => the value to indicate if the apc pvs voltage uplift workaround will
					be enabled;
				[4]: => fuse reading method, 0 for direct reading or 1 for SCM reading.
				When the value of the fuse bits specified by first 3 elements equals to the
				value in 4th element, the pvs voltage uplift workaround will be enabled.
- qcom,speed-bin-fuse-sel:	Array of 4 elements to indicate where to read the speed bin of the processor,
				and the fuse reading method.
				The 4 elements with index[0..3] are:
				[0]: => the fuse row number of the selector;
				[1]: => LSB bit position of the bits;
				[2]: => number of the bits;
				[3]: => fuse reading method, 0 for direct reading or 1 for SCM reading.
				This is required if cpr-fuse-uplift-disable-sel is present.
- qcom,cpr-uplift-voltage:	Uplift in microvolts used for increasing pvs init voltage. If this property is present,
				This is required if cpr-fuse-uplift-disable-sel is present.
- qcom,cpr-uplift-max-volt:	Maximum voltage in microvolts used for pvs voltage uplift workaround to limit
				the maximum pvs voltage.
				This is required if cpr-fuse-uplift-disable-sel is present.
- qcom,cpr-uplift-quotient:	Three numbers used for pvs voltage uplift workaround to be added to the target
				quotient for each corner.
				The 3 quotient increment with index[0..2] are:
				[0]: => for SVS corner target quotient;
				[1]: => for NORM corner target quotient;
				[2]: => for TURBO corner target quotient;
				This is required if cpr-fuse-uplift-disable-sel is present.
- qcom,cpr-uplift-speed-bin:	The speed bin value corresponding to one type of processor which needs to apply the
				pvs voltage uplift workaround.
				This is required if cpr-fuse-uplift-disable-sel is present.
- qcom,cpr-quotient-adjustment:	Array of three elements of CPR quotient adjustments for each corner.
				The 3 quotient adjustments with index[0..2] are:
				[0] => amount to add to the SVS quotient
				[1] => amount to add to the NORM quotient
				[2] => amount to add to the TURBO quotient
				If this property is specified, then the quotient adjustment values are added to the target
				quotient values read from fuses before writing them into the CPR GCNT target control registers.
				This property can be used to add static margin to the voltage rail managed by the CPR controller.
- vdd-apc-optional-prim-supply:	Present: Regulator of highest priority to supply VDD APC power
				Not Present: No such regulator.
- vdd-apc-optional-sec-supply:	Present: Regulator of second highest priority to supply VDD APC power.
				Not Present: No such regulator.
- qcom,cpr-speed-bin-max-corners: Array of quintuples in which each quintuple maps a CPU speed bin and PVS version to
				the maximum virtual voltage corner corresponding to the SVS, NORMAL and TURBO corners.
				The 5 elements in one quintuple are:
				[0]: => the speed bin of the CPU.
				[1]: => the PVS version of the CPU.
				[2]: => the max virtual voltage corner value corresponding to SVS corner for this speed bin.
				[3]: => the max virtual voltage corner value corresponding to NORMAL corner for this speed bin.
				[4]: => the max virtual voltage corner value corresponding to TURBO corner for this speed bin.
				No CPR target quotient scaling is applied on chips which have a speed bin + PVS version
				pair that does not appear in one of the quintuples in this property. If the property is
				specified, then quotient scaling is enabled for the TURBO corner. If this property is
				not specified, then no quotient scaling can take place.
- qcom,cpr-corner-map:		Array of elements of fuse corner value for each virtual corner.
				The location or 1-based index of an element in the list corresponds to
				the virtual corner value. For example, the first element in the list is the fuse corner
				value that virtual corner 1 maps to.
				This property is required if qcom,cpr-speed-bin-max-corners is present.
- qcom,cpr-corner-frequency-map: Array of tuples in which a tuple describes a corner to application processor frequency
				mapping.
				The 2 elements in one tuple are:
				[0]: => a virtual voltage corner.
				[1]: => the application processor frequency in Hz corresponding to the virtual corner.
				This property is required if qcom,cpr-speed-bin-max-corners is present.
- qcom,pvs-version-fuse-sel:	Array of 4 elements to indicate where to read the pvs version of the processor,
				and the fuse reading method.
				The 4 elements with index[0..3] are:
				[0]: => the fuse row number of the selector;
				[1]: => LSB bit position of the bits;
				[2]: => the number of bits;
				[3]: => fuse reading method, 0 for direct reading or 1 for SCM reading.
				This property is required if qcom,cpr-speed-bin-max-corners is present.
- qcom,cpr-quot-adjust-scaling-factor-max: The maximum allowed CPR target quotient scaling factor to use when
				calculating the quotient adjustment for a given virtual voltage corner. It
				corresponds to 'scaling' in this equation:
				quot_adjust = (freq_turbo - freq_corner) * scaling / 1000.
				This property is required if qcom,cpr-speed-bin-max-corners is present.
- mem-acc-supply:		Regulator to vote for the memory accelerator configuration.
				Not Present: memory accelerator configuration not supported.

Example:
	apc_vreg_corner: regulator@f9018000 {
		status = "okay";
		compatible = "qcom,cpr-regulator";
		reg = <0xf9018000 0x1000>, <0xfc4b8000 0x1000>;
		reg-names = "rbcpr", "efuse_addr";
		interrupts = <0 15 0>;
		regulator-name = "apc_corner";
		regulator-min-microvolt = <1>;
		regulator-max-microvolt = <12>;

		qcom,pvs-fuse = <22 6 5 1>;
		qcom,pvs-fuse-redun-sel = <22 24 3 2 1>;
		qcom,pvs-fuse-redun = <22 27 5 1>;

		qcom,pvs-voltage-table =
			<1050000 1150000 1350000>,
			<1050000 1150000 1340000>,
			<1050000 1150000 1330000>,
			<1050000 1150000 1320000>,
			<1050000 1150000 1310000>,
			<1050000 1150000 1300000>,
			<1050000 1150000 1290000>,
			<1050000 1150000 1280000>,
			<1050000 1150000 1270000>,
			<1050000 1140000 1260000>,
			<1050000 1130000 1250000>,
			<1050000 1120000 1240000>,
			<1050000 1110000 1230000>,
			<1050000 1100000 1220000>,
			<1050000 1090000 1210000>,
			<1050000 1080000 1200000>,
			<1050000 1070000 1190000>,
			<1050000 1060000 1180000>,
			<1050000 1050000 1170000>,
			<1050000 1050000 1160000>,
			<1050000 1050000 1150000>,
			<1050000 1050000 1140000>,
			<1050000 1050000 1140000>,
			<1050000 1050000 1140000>,
			<1050000 1050000 1140000>,
			<1050000 1050000 1140000>,
			<1050000 1050000 1140000>,
			<1050000 1050000 1140000>,
			<1050000 1050000 1140000>,
			<1050000 1050000 1140000>,
			<1050000 1050000 1140000>,
			<1050000 1050000 1140000>;
		qcom,cpr-voltage-ceiling = <1050000 1150000 1280000>;
		qcom,cpr-voltage-floor = <1050000 1050000 1100000>;
		vdd-apc-supply = <&pm8226_s2>;
		vdd-apc-optional-prim-supply = <&ncp6335d>;
		vdd-apc-optional-sec-supply = <&fan53555>;
		vdd-mx-supply = <&pm8226_l3_ao>;
		qcom,vdd-mx-vmax = <1350000>;
		qcom,vdd-mx-vmin-method = <1>;
		qcom,vdd-apc-step-up-limit = <1>;
		qcom,vdd-apc-step-down-limit = <1>;
		qcom,cpr-ref-clk = <19200>;
		qcom,cpr-timer-delay = <5000>;
		qcom,cpr-timer-cons-up = <1>;
		qcom,cpr-timer-cons-down = <2>;
		qcom,cpr-irq-line = <0>;
		qcom,cpr-step-quotient = <15>;
		qcom,cpr-up-threshold = <1>;
		qcom,cpr-down-threshold = <2>;
		qcom,cpr-idle-clocks = <5>;
		qcom,cpr-gcnt-time = <1>;
		qcom,cpr-apc-volt-step = <5000>;

		qcom,cpr-fuse-row = <138 1>;
		qcom,cpr-fuse-bp-cpr-disable = <36>;
		qcom,cpr-fuse-bp-scheme = <37>;
		qcom,cpr-fuse-target-quot = <24 12 0>;
		qcom,cpr-fuse-ro-sel = <54 38 41>;
		qcom,cpr-fuse-redun-sel = <138 57 1 1 1>;
		qcom,cpr-fuse-redun-row = <139 1>;
		qcom,cpr-fuse-redun-target-quot = <24 12 0>;
		qcom,cpr-fuse-redun-ro-sel = <46 36 39>;
		qcom,cpr-fuse-cond-min-volt-sel = <54 42 6 7 1>;
		qcom,cpr-cond-min-voltage = <1140000>;
		qcom,cpr-fuse-uplift-sel = <22 53 1 0 0>;
		qcom,cpr-uplift-voltage = <50000>;
		qcom,cpr-uplift-quotient = <0 0 120>;
		qcom,cpr-uplift-max-volt = <1350000>;
		qcom,cpr-uplift-speed-bin = <1>;
		qcom,speed-bin-fuse-sel = <22 0 3 0>;
		qcom,cpr-corner-map = <1 1 2 2 3 3 3 3 3 3 3 3>;
		qcom,cpr-corner-frequency-map =
				<1 300000000>,
				<2 384000000>,
				<3 600000000>,
				<4 787200000>,
				<5 998400000>,
				<6 1094400000>,
				<7 1190400000>,
				<8 1305600000>,
				<9 1344000000>,
				<10 1401600000>,
				<11 1497600000>,
				<12 1593600000>;
		qcom,pvs-version-fuse-sel = <22 4 2 0>;
		qcom,cpr-speed-bin-max-corners =
				<0 1 2 4 7>,
				<1 1 2 4 12>,
				<2 1 2 4 10>,
				<5 1 2 4 14>;
		qcom,cpr-quot-adjust-scaling-factor-max = <650>;
	};

